//
//  MikerItemCell.swift
//  MikerShop
//
//  Created by eme on 2016/12/12.
//  Copyright © 2016年 eme. All rights reserved.
//

import UIKit

public class MikerItemCell: UIView {

    var hasSelected:Bool = false{
        didSet{
            self.indicator.isHidden = !hasSelected
            if hasSelected == true {
                self.content_Lb.textColor = UIColor(hex: "e31436")
                self.header_Lb.textColor = UIColor(hex: "e31436")
            }else{
                self.content_Lb.textColor = UIColor(hex: "000000")
                self.header_Lb.textColor = UIColor(hex: "000000")
            }
        }
    }
    var labelMargin: CGFloat = 10
    var header_Lb = UILabel()
    var content_Lb:UILabel = UILabel()
    private var indicator = UIView()  //水平指示器
    var showTitle:String?{
        didSet{
            if let title = self.showTitle {
                self.content_Lb.text = title
                self.content_Lb.sizeToFit()
            }
        }
    }
  public  override init(frame: CGRect) {
        super.init(frame: frame)
        self.addSubview(self.header_Lb)
        self.header_Lb.textAlignment = .center
        self.header_Lb.textColor = UIColor.black
        self.header_Lb.font = UIFont(name: "Helvetica", size: 13)
        header_Lb.snp.makeConstraints{ make in
            make.top.equalTo(4)
            make.centerX.equalToSuperview()
            make.height.equalTo(13)
        }
        self.addSubview(self.content_Lb)
        self.content_Lb.textAlignment = .center
        self.content_Lb.textColor = UIColor.black
        self.content_Lb.font = UIFont(name: "Helvetica", size: 15)
        self.indicator.backgroundColor = UIColor(hex: "e31436")
        content_Lb.snp.makeConstraints{ make in
            make.top.equalTo(self.header_Lb.snp.bottom).offset(0)
            make.centerX.equalToSuperview()
            make.leading.equalTo(labelMargin)
            make.bottom.equalTo(0)
            make.width.greaterThanOrEqualTo(40)
        }
        self.addSubview(self.indicator)
        self.indicator.snp.makeConstraints{ make in
            make.bottom.equalTo(0)
            make.centerX.equalToSuperview()
            make.height.equalTo(4)
            make.leading.equalTo(self.content_Lb.snp.leading).offset(0)
            
        }
    }
    
   public required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
